package org.chen.domain.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;

import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;

@Data
@TableName("avatar_group")
public class AvatarGroup {
    @TableId(value = "id",type = IdType.ASSIGN_ID)
    private String id;
    private String avatarId;
    private String avatarName;
    @TableField(fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createdAt;
    private int numLooks;
    private String previewImageUrl;
    private String groupType;
    private String trainStatus;

    @JsonProperty("createdAt")
    public void setCreatedAtFromTimestamp(long timestamp) {
        this.createdAt = LocalDateTime.ofInstant(Instant.ofEpochSecond(timestamp), ZoneId.systemDefault());
    }
}